home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / AMOSList / AMOSLIST.0997 / 000259_amos-request@svcs1.digex.net_Mon Sep 22 20:31:35 1997.msg < prev    next >
Text File  |  1997-10-01  |  3KB  |  90 lines

  1. Received: from svcs1.digex.net (svcs1.digex.net [204.91.197.224])
  2.     by mail3.access.digex.net (8.8.5/8.8.5) with ESMTP id UAA24393
  3.     for <mcox@access.digex.net>; Mon, 22 Sep 1997 20:31:34 -0400 (EDT)
  4. Received: (from daemon@localhost)
  5.     by svcs1.digex.net (8.8.5/8.8.5) id QAA18501
  6.     for amos-out; Mon, 22 Sep 1997 16:50:06 -0400 (EDT)
  7. Received: from mail4.access.digex.net (mail4.access.digex.net [205.197.247.2])
  8.     by svcs1.digex.net (8.8.5/8.8.5) with ESMTP id QAA18498
  9.     for <amos-list@svcs1.digex.net>; Mon, 22 Sep 1997 16:50:05 -0400 (EDT)
  10. Received: from mailhost.sosbbs.com (sosbbs.com [204.186.168.100])
  11.     by mail4.access.digex.net (8.8.5/8.8.5) with SMTP id QAA17653
  12.     for <amos-list@access.digex.net>; Mon, 22 Sep 1997 16:49:59 -0400 (EDT)
  13. Received: from gbenjam (204.186.168.53) by mailhost.sosbbs.com
  14.  (EMWAC SMTPRS 0.81) with SMTP id <B0000109157@mailhost.sosbbs.com>;
  15.  Mon, 22 Sep 1997 16:50:40 -0400
  16. Message-ID: <B0000109157@mailhost.sosbbs.com>
  17. From: "Garfield Benjamin" <gbenjam@sosbbs.com>
  18. To: <amos-list@access.digex.net>
  19. Subject: Saving/Loading Arrays
  20. Date: Mon, 22 Sep 1997 16:59:31 -0400
  21. X-MSMail-Priority: Normal
  22. X-Priority: 3
  23. X-Mailer: Microsoft Internet Mail 4.70.1155
  24. MIME-Version: 1.0
  25. Content-Type: text/plain; charset=ISO-8859-1
  26. Content-Transfer-Encoding: 7bit
  27. Status: O
  28. X-Status: 
  29.  
  30.  
  31. > How would I load and save an array directly to disk BTW and know it will
  32. > work correctly when loaded back in? At the moment, im reading a 700
  33. > line file, 1 line at a time and putting it in the array that way.
  34.  
  35. Easy to do! Funny you should mention this as I converted my Side
  36. Shooter stage to directly load all arrays just a month back or so...
  37.  
  38. Anyway, just use VarPtr(ARRAYNAME(0)) to find the start of the Array.
  39. Then compute the number of bytes by multiplying the number of
  40. Array-elements by 4.
  41. Now, just BSave the area out to disk.
  42. As in...
  43.  
  44. ' Allocate TEST array...
  45. Dim TEST(9)
  46.  
  47. ' Fill TEST-array with values...
  48. For REP=0 To 9
  49.    TEST(REP)=REP*10
  50. Next REP
  51.  
  52. ' Define Pointer to start of TEST-array...
  53. VP=VarPtr(TEST(0))
  54.  
  55. ' Determine size of TEST-array to save...
  56. BYTESIZE=9*4 : Rem 9 elements*4bytes each
  57.  
  58. ' Save out the Array...
  59. BSave "RAM:TEST.BIN",VP to VP+BYTESIZE
  60. ' -------------------------------------------------------------------
  61.  
  62. Rem Now here's where we load it back in to see if it worked...
  63.  
  64. ' Nullify TEST-array...
  65. For REP=0 to 9
  66.    TEST(REP)=0
  67. Next REP
  68.  
  69. ' Define Pointer...
  70. VP=VarPtr(TEST(0))
  71.  
  72. ' Load in the Array...
  73. BLoad "RAM:TEST.BIN",VP
  74.  
  75. ' Show the results...
  76. For REP=0 to 9
  77.    print TEST(REP)
  78. Next REP
  79.  
  80. End
  81.  
  82.  
  83. Hope this helps!!
  84.  
  85.  
  86. Take Care
  87. GARFIELD
  88.  
  89.  
  90.